package com.itqf.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/12/19
 * @Time: 上午9:09
 */
@Configuration  //xml中<beans>
//@Component   RabbitMQConfig 类的对象
public class RabbitMQConfig {

//    @Bean
//    public FanoutExchange getFanoutExchange() {
//        return new FanoutExchange("boot-fanout-exchange", true, false);//String name, boolean durable, boolean autoDelete
//    }

    @Bean
    public TopicExchange getTopicExchange() {
        return new TopicExchange("boot-topic-exchange", true, false);//String name, boolean durable, boolean autoDelete
    }

    @Bean  //<bean>  构建对象
    public Queue queue(){
        return  new Queue("queue",true,false,false);
    }

    @Bean
    public Binding binding(TopicExchange topicExchange, Queue queue) {
        return BindingBuilder.bind(queue).to(topicExchange)
                .with("#.#");//aa.bb.cc.dd   a.b
        //如果exchange是direct|topic  那么需要.with("*.info");;
    }

}
